<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3" xmlns:head="http://www.w3.org/1999/html">
<head th:include="public/public_css::public_css ('预期到货通知单管理')"/>

<body style="background-color: #f2f2f2;">
<div class="layui-fluid larry-wrapper">
    <div class="layui-card">
        <div class="layui-row layui-col-space30">
            <div class="layui-col-xs24">
                <form class="layui-form layui-card-header  layui-card-header-auto" id="searchForm">
                    <div class="layui-inline">
                        <label class="layui-form-label">供应商名称</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" id="gysmc" name="gysmc" placeholder="供应商名称"/>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">ASN编号</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" id="asnbh" name="asnbh" placeholder="ASN编号"/>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">ASN类型</label>
                        <div class="layui-input-inline">
                            <select name="asnlx" id="flSelect" lay-search>
                            </select>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">创建时间</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" name="stime" id="stime"
                                   placeholder="yyyy-MM-dd HH:mm:ss"/>
                        </div>
                    </div>
                    <div class="layui-inline inline-search-btn">
                        <a class="layui-btn layui-btn-normal search_btn" lay-event="searchEvent"
                           data-type="reload">查询</a>
                    </div>
                    <div class="layui-inline inline-reset-btn">
                        <button type="reset" class="layui-btn layui-btn-normal" style="background-color: #40AFFE">重置
                        </button>
                    </div>
                    <div class="moreSearch" style="display: none">
                        <div class="layui-inline">
                            <label class="layui-form-label">码盘状态</label>
                            <select name="mpzt" lay-filter="aihao">
                                <option value=""></option>
                                <option value="">全部</option>
                                <option value="0">未码盘</option>
                                <option value="1">已码盘</option>
                            </select>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">审核状态</label>
                            <select name="shzt" lay-filter="aihao">
                                <option value=""></option>
                                <option value="">全部</option>
                                <option value="0">未审核</option>
                                <option value="1">已审核</option>
                            </select>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">打印状态</label>
                            <select name="dyzt" lay-filter="aihao">
                                <option value=""></option>
                                <option value="">全部</option>
                                <option value="0">未打印</option>
                                <option value="1">已打印</option>
                            </select>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">ASN状态</label>
                            <select name="asnzt" lay-filter="aihao">
                                <option value=""></option>
                                <option value="">全部</option>
                                <option value="0">创建</option>
                                <option value="1">部分收货</option>
                                <option value="2">完全收货</option>
                                <option value="3">订单取消</option>
                                <option value="4">ASN完成</option>
                            </select>
                        </div>
                    </div>
                </form>
                <div class="moreBtn"><i class="layui-icon layui-icon-triangle-d" style="color: #1E9FFF;"></i></div>
               <!-- <div style="    position: absolute; z-index: 9999; top: 180px; margin-left: 450px;">
                    <a type="button" class="layui-btn layui-btn-sm layui-btn-normal" id="test"><i class="layui-icon"></i>导入</a>
                </div>-->
                <!--顶部按钮展示区域 【 tpl-button 】 -->
                <div class="group-button tpl-button" id="toolbar">

                </div>
                <!--列表-->
                <section class="panel panel-padding layui-card-body">
                    <div class="pro">
                        <table id="table" class="table text-nowrap"></table>
                    </div>
                </section>
            </div>
        </div>
        <!--编辑用的-->
        <div class="layui-fluid larry-wrapper" id="bjEdit" style="display: none">
            <form action="" class="layui-form layui-form-pane" id="formEdit">
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label>ASN编号</label>
                        <div class="layui-form-inline">
                            <input type="text" class="layui-input" id="asnbhId" name="asnbh"
                                   disabled="disabled" style="width: 193px"/>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label>预计到货时间</label>
                        <div class="layui-form-inline">
                            <input type="text" class="layui-input" name="stime" id="stimeId"
                                   placeholder="yyyy-MM-dd HH:mm:ss" style="width: 193px"/>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label>优先级</label>
                        <div class="layui-form-inline">
                            <select id="yxjId" lay-filter="selFilter" disabled style="width: 193px">
                                <option value="1">1</option>
                                <option value="2">2</option>
                                <option value="3">3</option>
                            </select>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label>ASN类型</label>
                        <div class="layui-form-inline">
                            <select lay-ignore="lay-ignore" class="js-data-example-ajax" id="asnlxId"
                                    disabled="disabled"
                                    name="asnlx" select2 style="width: 193px" style="width: 193px"></select>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label>供应商编号</label>
                        <div class="layui-form-inline">
                            <select lay-ignore="lay-ignore" class="js-data-example-ajax" id="gysIds"
                                    style="width: 193px"
                                    disabled="disabled"
                                    name="gysid" select2></select>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label>审核状态</label>
                        <div class="layui-form-inline">
                            <input type="text" class="layui-input" id="shztId" name="shzt" style="width: 193px"
                                   disabled="disabled"/>
                        </div>
                    </div>
                </div>
                <input type="hidden" id="test">
            </form>
        </div>
    </div>
</div>
</body>
<div th:include="public/public_js::public_js"></div>
<div th:include="public/public_btn::public_btn"></div>
<style type="text/css">
    .moreBtn {
        width: 50px;
        height: 20px;
        text-align: center;
        color: #fff;
        line-height: 20px;
        background-color: #eee;
        position: relative;
        margin: 0 auto;
        cursor: pointer;
    }

    .moreBtn:before {
        content: '';
        display: block;
        width: 35px;
        height: 20px;
        position: absolute;
        transform: skewX(30deg);
        background: #eee;
        border-top-left-radius: 8px;
        left: -20px;
        top: 0;
    }

    .moreBtn:after {
        content: '';
        display: block;
        width: 35px;
        height: 20px;
        position: absolute;
        transform: skewX(-30deg);
        background: #eee;
        border-top-right-radius: 8px;
        top: 0;
        right: -20px;
    }
</style>
<script th:inline="javascript">
    $(function () {
        $(".moreBtn").on("click", function () {
            $(".moreSearch").toggle();
        });
    });
    var functions = [[${functions}]];
    layui.use(['list', 'layer', 'zzpUtils', 'form', 'jquery', 'laydate', 'tablebutton','upload'], function () {


        var zzpUtils = layui.zzpUtils,
            $ = layui.jquery,
            form = layui.form,
            laydate = layui.laydate,
            tablebtn = layui.tablebutton;
            upload = layui.upload;



        //执行实例
        var uploadInst = upload.render({
            elem: '#test' //绑定元素
            ,url: '/zxsswms/file/upload' //上传接口
            ,exts: 'xls|xlsx'
            ,accept: 'file'
            ,done: function(res){
                console.info("res");
                console.info(res);
                //上传完毕回调
                zzpUtils.action({
                    url: "/wmsEstimatedArrivalOrderDetailed/importWmsEstimatedExcle",
                    data: res.filePath,
                    success: function (data) {
                        setTimeout(function () {
                                layer.msg(data.title + '<br>' + data.message);
                        }, 500);
                        zzpUtils.refreshTable("#table");
                    }, error: function (xhr, textStatus) {
                        console.log(textStatus);
                        console.log(xhr)
                    }
                })
            }

            ,error: function(){
                //请求异常回调
            }
        });

        laydate.render({
            elem: '#stimeId'
            , theme: '#20a0ff'
            , range: '~'//练起来
        });
        /*select2单选
      * ASN类型
      * */
        zzpUtils.select2({
            elem: "#asnlxId",
            url: "/wmsPurchaseOrder/getSelectLx",
            minimumInputLength: 0
        });
        /*
        * 供应商编号
        * */
        zzpUtils.select2({
            elem: "#gysIds",
            url: "/wmsPurchaseOrder/getGysmc",
            minimumInputLength: 0
        });
        tablebtn.buildOnClick({
            type: 1,
            temp: $("#function_tpl"),
            functions: functions.headBtn,
            row: null,
            event: {
                //查询
                searchEvent: function () {
                    zzpUtils.refreshTable("#table");
                },
                /*新增*/
                addEvent: function (data) {
                    add();
                },
                //PO提取
                PO_AddEvent: function (data) {
                    PoAdd();
                },
                /*编辑*/
                editEvent: function (data) {
                    if (data.row != undefined) {
                        upDialog(data);
                    }
                },
                //标记
                signEvent: function (data) {
                    if (data.row != undefined) {
                        var ids = [];
                        ids.push(data.row.id);
                        startDialog(ids);
                    } else {
                        var arr = [];
                        var $rows = $table.bootstrapTable('getSelections');
                        if ($rows.length > 0) {
                            arr = $.map($rows, function (row) {
                                return row.id;
                            })
                            startDialog(arr);
                        } else {
                            layer.msg("至少选择一条数据");
                        }
                    }
                },
                /*明细*/
                getEvent: function (data) {
                    if (data.row != undefined) {
                        btnDialog(data.row);
                    }
                },
                /*删除*/
                deleteEvent: function (data) {
                    if (data.row != undefined) {
                        var ids = [];
                        ids.push(data.row.id)
                        delDialog(ids);
                    }
                },
                //生成质检单
                generateEvent: function (data) {
                    if (data.row != undefined) {
                        var ids = [];
                        ids.push(data.row.id);
                        zhiJian(ids);
                    } else {
                        var arr = [];
                        var $rows = $table.bootstrapTable('getSelections');
                        if ($rows.length > 0) {
                            arr = $.map($rows, function (row) {
                                return row.id;
                            })
                            zhiJian(arr);
                        } else {
                            layer.msg("至少选择一条数据");
                        }
                    }
                },
                //打印
                printEvent: function (data) {
                    if (data.row != undefined) {
                        var ids = [];
                        ids.push(data.row.id);
                        btn_print(ids);
                    } else {
                        var arr = [];
                        var $rows = $table.bootstrapTable('getSelections');
                        if ($rows.length > 0) {
                            arr = $.map($rows, function (row) {
                                return row.id;
                            })
                            btn_print(arr);
                        } else {
                            layer.msg("至少选择一条数据");
                        }
                    }
                },
                //附件管理
                accessoryEvent: function (data) {
                    if (data.row != undefined) {
                        btn_fjsc(data.row.id);
                    }
                },
                //查看ASN收货
                AsnEvent: function (data) {
                    asnDialog(data.row);
                },
                //PO提取
                importEvent: function (data) {
                    importDialog();
                },
            }
        });
        //初始化
        zzpUtils.webSocket.init();

        //新增预期到货通知
        function add() {
            zzpUtils.dialog({
                title: "新增预期到货通知",
                type: 2,
                content: "/yqdh/addYqdh",
                area: ['90%', '90%'], //设置dialog大小，也可以不设置，
                end: function () {//增加成功后刷新
                    zzpUtils.refreshTable("#table");
                }
            });
        }

        //打印
        function btn_print(ids) {

            zzpUtils.confirm("您确认要打印？", function (index) {
                zzpUtils.action({
                    url: "/wmsEstimatedArrivalOrder/print",
                    data: JSON.stringify({ids: ids}),
                    success: function (data) {
                        console.log(data);
                        var LODOP = getLodop();
                        LODOP.PRINT_INIT('打印供货清单');
                        for (var i = 0; i < data.length; i++) {
                            //ADD_PRINT_HTM(Top,Left,Width,Height,strHtmlContent)
                            LODOP.ADD_PRINT_TEXT(0, 0, 300, 30, "供货清单 供应商：");
                            LODOP.SET_PRINT_STYLEA(0, 'FontSize', 13);
                            LODOP.ADD_PRINT_TEXT(0, 150, 300, 30, data[i].gys);
                            LODOP.SET_PRINT_STYLEA(0, 'FontSize', 13);
                            var oDate = new Date(); //实例一个时间对象；
                            var time = oDate.getFullYear() + '-' + (oDate.getMonth() + 1) + '-' + oDate.getDate() + ' ' + oDate.getHours() + ':' + oDate.getMinutes() + ':' + oDate.getSeconds();
                            LODOP.ADD_PRINT_TEXT(0, 500, 240, 30, "打印时间：");
                            LODOP.SET_PRINT_STYLEA(0, 'FontSize', 12);
                            LODOP.ADD_PRINT_TEXT(0, 600, 240, 30, time);
                            LODOP.SET_PRINT_STYLEA(0, 'FontSize', 12);
                            //高 left width height
                            LODOP.ADD_PRINT_RECT(30, 5, 750, 30, 0, 0);//画一个矩形
                            LODOP.ADD_PRINT_TEXT(35, 20, 300, 20, "发货通知");
                            LODOP.SET_PRINT_STYLEA(0, 'FontSize', 12);
                            LODOP.ADD_PRINT_RECT(60, 5, 750, 100, 0, 0);//画一个矩形
                            //ADD_PRINT_HTM(Top,Left,Width,Height,strHtmlContent)
                            LODOP.ADD_PRINT_TEXT(65, 20, 200, 20, "客户名称");
                            LODOP.SET_PRINT_STYLEA(0, 'FontSize', 11);
                            LODOP.ADD_PRINT_TEXT(65, 85, 400, 20, data[i].kh);
                            LODOP.SET_PRINT_STYLEA(0, 'FontSize', 11);
                            LODOP.ADD_PRINT_TEXT(65, 350, 200, 20, "收货地址");
                            LODOP.SET_PRINT_STYLEA(0, 'FontSize', 11);
                            LODOP.ADD_PRINT_TEXT(65, 420, 400, 20, data[i].shdz);
                            LODOP.SET_PRINT_STYLEA(0, 'FontSize', 11);
                            LODOP.ADD_PRINT_TEXT(105, 20, 200, 20, "送货方");
                            LODOP.SET_PRINT_STYLEA(0, 'FontSize', 11);
                            LODOP.ADD_PRINT_TEXT(105, 85, 200, 20, "");
                            LODOP.SET_PRINT_STYLEA(0, 'FontSize', 11);
                            LODOP.ADD_PRINT_TEXT(105, 350, 200, 20, "采购单号");
                            LODOP.SET_PRINT_STYLEA(0, 'FontSize', 11);
                            LODOP.ADD_PRINT_TEXT(105, 420, 400, 20, data[i].cgdh);
                            LODOP.SET_PRINT_STYLEA(0, 'FontSize', 11);
                            //高 left width height
                            LODOP.ADD_PRINT_RECT(170, 5, 750, 30, 0, 0);//画一个矩形
                            LODOP.ADD_PRINT_TEXT(175, 20, 300, 20, "发货单明细");
                            LODOP.SET_PRINT_STYLEA(0, 'FontSize', 12);
                            LODOP.ADD_PRINT_RECT(200, 5, 750, 100, 0, 0);//画一个矩形
                            LODOP.ADD_PRINT_TEXT(205, 20, 200, 20, "发货单入库码");
                            LODOP.SET_PRINT_STYLEA(0, 'FontSize', 11);
                            LODOP.ADD_PRINT_BARCODE(205, 130, 300, 40, "EAN128B", data[i].fhdrkm);
                            LODOP.ADD_PRINT_TEXT(255, 20, 200, 20, "制单日期");
                            LODOP.SET_PRINT_STYLEA(0, 'FontSize', 11);
                            LODOP.ADD_PRINT_TEXT(255, 90, 400, 20, data[i].zdrq);
                            LODOP.SET_PRINT_STYLEA(0, 'FontSize', 11);
                            LODOP.ADD_PRINT_TEXT(255, 300, 200, 20, "发货日期");
                            LODOP.SET_PRINT_STYLEA(0, 'FontSize', 11);
                            LODOP.ADD_PRINT_TEXT(255, 370, 400, 20, data[i].fhrq);
                            LODOP.SET_PRINT_STYLEA(0, 'FontSize', 11);
                            //下面是明细
                            LODOP.ADD_PRINT_RECT(310, 5, 750, 30, 0, 0);//画一个矩形
                            LODOP.ADD_PRINT_TEXT(315, 20, 300, 20, "供货清单明细");
                            LODOP.SET_PRINT_STYLEA(0, 'FontSize', 12);
                            var trs = '';
                            for (var j = 0; j < data[i].detail.length; j++) {
                                trs += '<tr>\n' +
                                    /* '<td width="150px"  style="border: 1px solid #000;height:18px"><b>'+(j+1)+'</b></td>\n' +*/
                                    '<td width="220px" style="border: 1px solid #000;height:18px"><b>' + data[i].detail[j].hpbh + '</b></td>\n' +
                                    '<td width="220px" style="border: 1px solid #000;height:18px"><b>' + data[i].detail[j].hpmc + '</b></td>\n' +
                                    '<td width="260px" style="border: 1px solid #000;height:18px"><b>' + data[i].detail[j].gg + '</b></td>\n' +
                                    '<td width="180px" style="border: 1px solid #000;height:18px"><b>' + data[i].detail[j].nc + '</b></td>\n' +
                                    '<td width="180px" style="border: 1px solid #000;height:18px"><b>' + data[i].detail[j].ms + '</b></td>\n' +
                                    '<td width="180px" style="border: 1px solid #000;height:18px"><b>' + data[i].detail[j].hppc + '</b></td>\n' +
                                    '<td width="220px" style="border: 1px solid #000;height:18px"><b>' + data[i].detail[j].scrq + '</b></td>\n' +
                                    '<td width="220px" style="border: 1px solid #000;height:18px"><b>' + data[i].detail[j].yqsl + '</b></td>\n' +
                                    '</tr>';
                            }
                            LODOP.ADD_PRINT_TABLE(340, 3, 755, 280, '<table border=0 cellSpacing=0 cellPadding=0  width="100%">\n' +
                                '                  <tr>\n' +
                                /* '                    <td width="150px"  style="border: 1px solid #000;height:18px"><b>序号</b></td>\n' +*/
                                '                    <td width="220px" style="border: 1px solid #000;height:18px"><b>货品编号</b></td>\n' +
                                '                    <td width="260px" style="border: 1px solid #000;height:18px"><b>货品名称</b></td>\n' +
                                '                    <td width="220px" style="border: 1px solid #000;height:18px"><b>规格</b></td>\n' +
                                '                    <td width="160px"  style="border: 1px solid #000;height:18px"><b>NC编码</b></td>\n' +
                                '                    <td width="160px" style="border: 1px solid #000;height:18px"><b>主单位</b></td>\n' +
                                '                    <td width="180px" style="border: 1px solid #000;height:18px"><b>货品批次</b></td>\n' +
                                '                    <td width="220px" style="border: 1px solid #000;height:18px"><b>生产日期</b></td>\n' +
                                '                    <td width="230px" style="border: 1px solid #000;height:18px"><b>主单位数量</b></td>\n' +
                                '\n' +
                                '                  </tr>' + trs + '<tfoot>\n' +
                                '\n' +
                                '                  </tfoot></table>');

                            if (i >= 0) {
                                LODOP.NewPage();//分页
                            }
                        }
                        LODOP.PREVIEW();
                    }, error: function (xhr, textStatus) {
                        console.log(textStatus);
                        console.log(xhr)
                    }
                })
            })
        }

        //PO提取
        function PoAdd() {
            zzpUtils.dialog({
                title: "提取PO",
                type: 2,
                content: "/yqdh/addPO",
                area: ['95%', '95%'], //设置dialog大小，也可以不设置，
                end: function () {//增加成功后刷新
                    zzpUtils.refreshTable("#table");
                }
            });

        }

        //查看预期到货明细
        function btnDialog(rows) {
            var index12;
            var shzt=rows.shzt;
            var gysid=rows.gysid;
            if (rows.shzt == 0) {//未审核
                layer.open({
                    title: "查看明细",
                    type: 2,
                    content: "/zxsswms/yqdh/getMingXiInfo?id=" + rows.id+"&shzt="+shzt+"&gysid="+gysid,
                    area: ['90%', '85%'], //设置dialog大小，也可以不设置，
                    btn: ['通过审核', '取消'],
                    btn1: function (index, layero) {
                        index12 = index;
                        var body = layer.getChildFrame('body', index);
                        var iframeWin = window[layero.find('iframe')[0]['name']];
                        var ssyqdid = iframeWin.shenhe();
                        var ids = [];
                        ids.push(ssyqdid);
                        zzpUtils.confirm("是否确认通过审核", function (index) {
                            zzpUtils.action({
                                url: "/wmsEstimatedArrivalOrder/auditing",
                                data: JSON.stringify({ids: ids}),
                                success: function (data) {
                                    setTimeout(function () {
                                        if (data.type == 'success') {
                                            layer.msg(data.title);
                                        } else {
                                            layer.msg(data.message);
                                        }
                                        layer.close(index12);
                                    }, 500);
                                    zzpUtils.refreshTable("#table");
                                }, error: function (xhr, textStatus) {
                                    console.log(textStatus);
                                    console.log(xhr)
                                }
                            })
                        })
                        return false;
                    },
                    btn2: function (index, layero) {
                        layer.close(index);
                    }
                });
            } else {
                layer.open({
                    title: "查看明细",
                    type: 2,
                    content: "/zxsswms/yqdh/getMingXiInfo?id=" + rows.id+"&shzt="+shzt+"&gysid="+gysid,
                    area: ['90%', '85%'], //设置dialog大小，也可以不设置，
                    btn: ['取消'],
                    btn1: function (index, layero) {
                        layer.close(index);
                    },
                    end: function () {//修改成功后刷新
                        zzpUtils.refreshTable("#table");
                    }
                });
            }

        }

        //查看ASN收货
        function asnDialog(rows) {
            layer.open({
                title: "查看ASN收货",
                type: 2,
                content: "/zxsswms/yqdh/getAsnMx?id=" + rows.id,
                area: ['80%', '70%'], //设置dialog大小，也可以不设置，
                btn: ['取消'],
                btn1: function (index, layero) {
                    layer.close(index);
                }
            });

        }

        //标记
        function startDialog(ids) {
            zzpUtils.confirm("您将标记选择的订单", function (index) {
                zzpUtils.action({
                    url: "/wmsEstimatedArrivalOrder/fulfil",
                    data: JSON.stringify({ids: ids}),
                    success: function (data) {
                        setTimeout(function () {
                            if (data.type == 'success') {
                                layer.msg(data.title);
                            } else {
                                layer.msg(data.message);
                            }
                        }, 500);
                        zzpUtils.refreshTable("#table");
                    }, error: function (xhr, textStatus) {
                        console.log(textStatus);
                        console.log(xhr)
                    }
                })
            })
            return false;
        }

        //生成质检单
        function zhiJian(ids) {
            zzpUtils.confirm("确认生成质检单？", function (index) {
                zzpUtils.action({
                    url: "/wmsEstimatedArrivalOrder/getBill",
                    data: JSON.stringify({ids: ids}),
                    success: function (data) {
                        setTimeout(function () {
                            if (data.type == 'success') {
                                layer.msg(data.title);
                            } else {
                                layer.msg(data.message);
                            }
                        }, 500);
                        zzpUtils.refreshTable("#table");
                    }, error: function (xhr, textStatus) {
                        console.log(textStatus);
                        console.log(xhr)
                    }
                })
            })
            return false;
        }

        //附件上传
        function btn_fjsc(id) {
            zzpUtils.dialog({
                title: "附件管理",
                type: 2,
                content: "/yqdh/getEnclosure?id=" + id,
                area: ['80%', '80%'], //设置dialog大小，也可以不设置，
                end: function () {//增加成功后刷新
                    //zzpUtils.refreshTable("#table");
                }
            });
        }

        //删除
        function delDialog(ids) {

            zzpUtils.confirm("您将删除选择的数据", function (index) {
                zzpUtils.action({
                    url: "/wmsEstimatedArrivalOrder/del",
                    data: JSON.stringify({ids: ids}),
                    success: function (data) {
                        setTimeout(function () {
                            if (data.type == 'success') {
                                layer.msg(data.title);
                            } else {
                                layer.msg(data.message);
                            }
                        }, 500);
                        zzpUtils.refreshTable("#table");
                    }, error: function (xhr, textStatus) {
                        console.log(textStatus);
                        console.log(xhr)
                    }
                })
            })
            return false;
        }

       function importDialog(){
           $("#test").show();
           document.getElementById("test").click();

       }

        //编辑预期到货通知
        function upDialog(data) {
            console.log(data);
            layer.open({
                type: 1,
                title: '修改预期到货通知',
                area: ['55%', '55%'],
                content: $("#bjEdit"),//支持获取DOM元素
                btn: ['保存', '取消'], //按钮
                success: function (index) {
                    $('#asnbhId').val(data.row.asnbh);
                    $("#yxjId").val(data.row.yxj);
                    form.render('select');
                    $('#asnlxId').html('<option value="' + data.row.asnlx + '">' + data.row.show_asnlx + '</option>').trigger("change");
                    $('#gysIds').html('<option value="' + data.row.gysid + '">' + data.row.gysbh + " " + data.row.gysmc + '</option>').trigger("change");
                    $('#stimeId').val(data.row.yjdhsjks.substring(0, 10) + ' ~ ' + data.row.yjdhsjjs.substring(0, 10));
                    if (data.row.shzt == 0) {
                        $('#shztId').val('不自动');
                    } else {
                        $('#shztId').val('自动');
                    }
                },
                yes: function (index2) {
                    var asnbh = $("#asnbhId").val();//ASN编号
                    var stime = $("#stimeId").val();//预计到货时间
                    var yxj = $("#yxjId").val();//优先级
                    var selectId = $("#asnlxId ").select2("val");//ASN类型
                    var gysId = $("#gysIds ").select2("val");//供应商
                    var arr = stime.split("~");
                    var pass3 = {};
                    pass3.asnbh = asnbh;
                    pass3.yxj = yxj;
                    pass3.shzt = data.row.shzt;
                    pass3.asnlx = selectId;
                    pass3.gysid = gysId;
                    pass3.locking = 2;
                    pass3.gysmc = $("#gysIds").select2("data")[0].text;
                    pass3.yjdhsjks = arr[0];
                    pass3.yjdhsjjs = arr[1];
                    pass3.asnzt = data.row.asnzt;
                    pass3.dycgdbh = data.row.dycgdbh;
                    pass3.id = data.row.id;
                    pass3.dyzt = data.row.dyzt;
                    zzpUtils.confirm("您确认要编辑吗", function (index) {
                        zzpUtils.action({
                            url: "/wmsEstimatedArrivalOrder/edit",
                            data: JSON.stringify(pass3),
                            success: function (data) {
                                setTimeout(function () {
                                    layer.close(index2);
                                    layer.close(index); //再执行关闭
                                    if (data.type == 'success') {
                                        layer.msg(data.title);
                                    } else {
                                        layer.msg(data.message);
                                    }
                                }, 500);
                                zzpUtils.refreshTable("#table");
                            }, error: function (xhr, textStatus) {
                                console.log(textStatus);
                                console.log(xhr)
                            }
                        })
                    })
                },
                btn2: function (index) {
                    layer.close(index);
                }
            });

        }

        //查询ASN类型
        zzpUtils.select({
            elem: "#flSelect",    //dom
            url: "/wmsPurchaseOrder/getAsnLx"
        });
        laydate.render({
            elem: '#stime'
            , theme: '#20a0ff'
            , range: '~'//练起来
        })
        var $table = zzpUtils.table({
            elem: '#table',
            isApi: true,
            isOperate: true,
            //functions: functions.tableBtn,
            pagination: true,
            url: '/wmsEstimatedArrivalOrder/list',
            columns: [{
                field: '',
                checkbox: true
            }, {
                field: 'ckmc',
                title: '仓库',
                visible: false
            }, {
                field: 'hzmc',
                title: '货主'
            }, {
                field: 'gysmc',
                title: '供应商名称'
            }, {
                field: 'asnbh',
                title: 'ASN编号'
            }, {
                field: 'show_asnlx',
                title: 'ASN类型'
            }, {
                field: 'show_asnzt',
                title: 'ASN状态'
            }, {
                field: 'show_mpzt',
                title: '码盘状态'
            }, {
                field: 'cjsj',
                title: '创建时间'
            }, {
                field: 'show_shzt',
                title: '审核状态'
            }, {
                field: 'show_yxj',
                title: '优先级',
                visible: false
            }, {
                field: 'zdr',
                title: '制单人',
                visible: false
            }, {
                field: 'ddshr',
                title: '审核人',
                visible: false
            }, {
                field: 'show_dyzt',
                title: '打印状态',
                visible: false
            }],
            queryParams: function () {//查询条件
                return zzpUtils.getFormJson($("#searchForm"));
            },
            detailFormatter: function (index, row) {
                return "这里就没有确定过11";
            },
            /*定义表格右侧按钮*/
            operateFormatter: operateFormatter
        });

        /*表格右侧按钮*/
        function operateFormatter(value, row, index) {
            var button = '', buttons1 = '', buttons2 = '';
            var buttons = '<a class="tooltip2" id="tooltip' + row.id + '" data-tooltip-content="#tool' + row.id + '" id="btn_start"><i class="layui-icon layui-icon-more"></i></a>'
                + '<div class="tooltip_templates">'
                + '<span id="tool' + row.id + '">';
            for (var i = 0; i < functions.tableBtn.length; i++) {
                var item = functions.tableBtn[i];
                var btn = '<a class="layui-btn layui-btn-xs layui-btn-normal" lay-event="' + functions.tableBtn[i].event + '">'
                    + functions.tableBtn[i].name
                    + '</a>';
                if (item.event === 'getEvent' || item.event === 'accessoryEvent') {
                    buttons1 += '<button class="layui-btn layui-btn-xs layui-btn-normal" lay-event="' + item.event + '">'
                        + item.name
                        + '</button>';
                } else {
                    if (row.shzt == '0') {
                        if (functions.tableBtn[i].name == '编辑' || functions.tableBtn[i].name == '删除'
                            || functions.tableBtn[i].name == '查看ASN收货' || functions.tableBtn[i].name == '打印') {
                            buttons2 += btn;
                        }
                    } else if (row.asnzt == '1') {//部分收货
                        if (functions.tableBtn[i].name == '查看ASN收货' || functions.tableBtn[i].name == '标记' || functions.tableBtn[i].name == '打印') {
                            buttons2 += btn;
                        }
                    } else if (row.zjzt == '0' && row.shzt == '1' && (row.asnzt == '2' || row.asnzt == '4')) {
                        if (functions.tableBtn[i].name == '查看ASN收货' || functions.tableBtn[i].name == '打印'
                            || functions.tableBtn[i].name == '生成质检单') {
                            buttons2 += btn;
                        }
                    } else {
                        if (functions.tableBtn[i].name == '查看ASN收货' || functions.tableBtn[i].name == '打印'
                        ) {
                            buttons2 += btn;
                        }
                    }
                }
            }
            button += buttons1;
            button += buttons;
            button += buttons2;
            button += '</span>'
                + '</div>';
            return button;
        }

        //查询
        /* $(".inline-search-btn").on('click', function () {
             zzpUtils.refreshTable("#table");
         })*/

    });


</script>
</html>